<div [@routerTransition]>
    <div class="m-subheader">
        <div class="row align-items-center">
            <div class="mr-auto col-auto">
                <h3 class="m-subheader__title m-subheader__title--separator">
                    <span>交接单</span>
                </h3>
                <span class="m-section__sub">
                    交接单签收
                </span>
            </div>
            <div class="col text-right mt-3 mt-md-0"></div>
        </div>
    </div>
    <div class="m-content">
        <div class="m-portlet m-portlet--mobile">
            <div class="m-portlet__body">
                <div class="tabbable-line">
                    <ul class="nav nav-tabs  m-tabs-line">
                        <li class="nav-item m-tabs__item">
                            <p-tabMenu [model]="tabs" [activeItem]="tabs[0]">
                                <ng-template
                                    pTemplate="item"
                                    let-item
                                    let-i="index"
                                >
                                    <div
                                        style="position: relative; text-align: center; min-width: 5em;"
                                    >
                                        <div
                                            class="ui-menuitem-text"
                                            (click)="tabTypeClick(item.value)"
                                        >
                                            {{ item.label }}
                                        </div>
                                    </div>
                                </ng-template>
                            </p-tabMenu>
                        </li>
                    </ul>
                </div>
                <form class="horizontal-form" autocomplete="off">
                    <div class="m-form m-form--label-align-right">
                        <div class="row align-items-center m--margin-bottom-10">
                            <div class="col-xl-12">
                                <div
                                    class="form-group m-form__group align-items-center"
                                >
                                    <div class="input-group">
                                        <input
                                            [(ngModel)]="filterText"
                                            name="filterText"
                                            autoFocus
                                            class="form-control m-input"
                                            [placeholder]="
                                                l('SearchWithThreeDot')
                                            "
                                            type="text"
                                        />
                                        <span class="input-group-btn">
                                            <button
                                                (click)="getDeliveryRecords()"
                                                class="btn btn-primary"
                                                type="submit"
                                            >
                                                <i
                                                    class="flaticon-search-1"
                                                    [attr.aria-label]="
                                                        l('Search')
                                                    "
                                                ></i>
                                            </button>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div
                            class="row m--margin-bottom-10"
                            [hidden]="!advancedFiltersAreShown"
                        >
                            <div class="col-md-6">
                                <div class="form-group">
                                    <select
                                        name="isReceived"
                                        [(ngModel)]="isReceived"
                                        class="form-control"
                                    >
                                        <option value="false">未签收</option>
                                        <option value="true">已签收 </option>
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div
                            class="row margin-bottom-10"
                            *ngIf="advancedFiltersAreShown"
                        >
                            <div class="col-sm-12 text-right">
                                <button
                                    class="btn btn-metal"
                                    (click)="getDeliveryRecords()"
                                >
                                    <i class="fa fa-sync"></i>
                                    {{ 'Refresh' | localize }}
                                </button>
                            </div>
                        </div>
                        <div class="row margin-bottom-10">
                            <div class="col-sm-12">
                                <span
                                    class="clickable-item text-muted"
                                    *ngIf="!advancedFiltersAreShown"
                                    (click)="
                                        advancedFiltersAreShown = !advancedFiltersAreShown
                                    "
                                    ><i class="fa fa-angle-down"></i>
                                    {{ 'ShowAdvancedFilters' | localize }}</span
                                >
                                <span
                                    class="clickable-item text-muted"
                                    *ngIf="advancedFiltersAreShown"
                                    (click)="
                                        advancedFiltersAreShown = !advancedFiltersAreShown
                                    "
                                    ><i class="fa fa-angle-up"></i>
                                    {{ 'HideAdvancedFilters' | localize }}</span
                                >
                            </div>
                        </div>
                    </div>
                </form>

                <div class="row align-items-center">
                    <!--<Primeng-TurboTable-Start>-->
                    <div
                        class="primeng-datatable-container"
                        [busyIf]="primengTableHelper.isLoading"
                    >
                        <p-table
                            #dataTable
                            (onLazyLoad)="getDeliveryRecords($event)"
                            [value]="primengTableHelper.records"
                            rows="{{
                                primengTableHelper.defaultRecordsCountPerPage
                            }}"
                            [paginator]="false"
                            [lazy]="true"
                            [scrollable]="true"
                            ScrollWidth="100%"
                            [responsive]="primengTableHelper.isResponsive"
                            [resizableColumns]="
                                primengTableHelper.resizableColumns
                            "
                        >
                            <ng-template pTemplate="header">
                                <tr>
                                    <th
                                        style="width: 130px"
                                        *ngIf="!isReceived && isGranted('Mes58.Pages.Delivery.Confirm')"
                                    >
                                        {{ 'Actions' | localize }}
                                    </th>
                                    <th style="width: 150px">
                                        任务号
                                    </th>
                                    <th style="width: 150px">
                                        图号
                                    </th>
                                    <th style="width: 150px">
                                        产品名称
                                    </th>
                                    <th style="width: 150px">
                                        订制车间
                                    </th>

                                    <th style="width: 150px">
                                        合格证号
                                    </th>

                                    <th style="width: 80px">
                                        合格证数量
                                    </th>
                                    <th style="width: 150px">
                                        例外放行单
                                    </th>

                                    <th style="width: 80px">
                                        放行单数量
                                    </th>
                                </tr>
                            </ng-template>
                            <ng-template
                                pTemplate="body"
                                let-record="$implicit"
                            >
                                <tr>
                                    <td
                                        style="width: 130px"
                                        *ngIf="!isReceived && isGranted('Mes58.Pages.Delivery.Confirm')"
                                    >
                                        <div
                                            class="btn-group dropdown"
                                            dropdown
                                            container="body"
                                        >
                                            <button
                                                dropdownToggle
                                                class="dropdown-toggle btn btn-sm btn-primary"
                                            >
                                                <i class="fa fa-cog"></i
                                                ><span class="caret"></span>
                                                {{ 'Actions' | localize }}
                                            </button>
                                            <ul
                                                class="dropdown-menu"
                                                *dropdownMenu
                                            >
                                                <li>
                                                    <a
                                                        href="javascript:;"
                                                        (click)="
                                                            confirm(record)
                                                        "
                                                        >签收</a
                                                    >
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                    <td style="width: 150px">
                                        {{ record.taskCode }}
                                    </td>
                                    <td style="width: 150px">
                                        {{ record.drawingCode }}
                                    </td>
                                    <td style="width: 150px">
                                        {{ record.drawingName }}
                                    </td>
                                    <td style="width: 150px">
                                        {{ record.sourceId }}
                                    </td>

                                    <td style="width: 150px">
                                        {{ record.certificateId }}
                                    </td>

                                    <td style="width: 80px">
                                        {{ record.certificateQuantity }}
                                    </td>
                                    <td style="width: 150px">
                                        {{ record.exceptionalPassId }}
                                    </td>

                                    <td style="width: 80px">
                                        {{
                                            record.exceptionalPassQuantity === 0
                                                ? ''
                                                : record.exceptionalPassQuantity
                                        }}
                                    </td>
                                </tr>
                            </ng-template>
                        </p-table>
                        <div
                            class="primeng-no-data"
                            *ngIf="primengTableHelper.totalRecordsCount == 0"
                        >
                            {{ 'NoData' | localize }}
                        </div>
                        <div class="primeng-paging-container">
                            <p-paginator
                                [rows]="
                                    primengTableHelper.defaultRecordsCountPerPage
                                "
                                #paginator
                                (onPageChange)="getDeliveryRecords($event)"
                                [totalRecords]="
                                    primengTableHelper.totalRecordsCount
                                "
                                [rowsPerPageOptions]="
                                    primengTableHelper.predefinedRecordsCountPerPage
                                "
                            >
                            </p-paginator>
                            <span class="total-records-count">
                                {{
                                    'TotalRecordsCount'
                                        | localize
                                            : primengTableHelper.totalRecordsCount
                                }}
                            </span>
                        </div>
                    </div>
                    <!--<Primeng-TurboTable-End>-->
                </div>
            </div>
        </div>
    </div>
</div>
